package com.stonedt.spider.serviceImpl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.stonedt.spider.util.ApiCallUtil;
import org.springframework.stereotype.Service;

/**
 * @Author: 康涵博
 * @ClassName: ApiCallController
 * @Time: 2024/4/29 16:21
 * @Description:
 */
//@RestController
@Service
public class ApiCallService {

    public JSONObject apiCall(String prompt){

        String url = ApiCallUtil.getUrlFromProperties("api_url");
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("prompt",prompt);
        System.out.println("JSON:"+jsonObject);
        String response = ApiCallUtil.doPost(url, jsonObject);
//        JSONObject jsonObject1 = new JSONObject();
//        jsonObject1.put("response",response);
//        jsonObject1.getJSONObject("response");
//        jsonObject1.getJSONObject(response);
        return JSON.parseObject(response);
    }
}
